﻿@using SCMS.Resources
@model SCMS.UI.Models.PPModel
<div class="partialViewCard">
    <div class="partialViewCardHeader"><h3>@Resources_frank.Global_String_ProcurementPlan :: @Model.EntityPP.ProjectDonor.ProjectNumber</h3></div>
    <br />

    <table width="98%" align="center" cellpadding="0" class="cardTable">
        <tr>
            <th align="center" width="33%">
                @Resources_frank.OrderRequest_AddPPItems2OR_OfficePreparing
            </th>
            <th align="center" width="33%">
                @Resources_frank.Global_String_PreparedByName
            </th>
            <th align="center" colspan="2">
                @Resources_frank.Global_String_Date
            </th>
        </tr>
        <tr>
            <td align="center" valign="top">
                @Model.EntityPP.CountrySubOffice.Name
            </td>
            <td align="center" valign="top">
                @Model.EntityPP.Staff.Person.FirstName
                &nbsp;
                @Model.EntityPP.Staff.Person.OtherNames
            </td>
            <td align="center" colspan="2">
                @Model.EntityPP.PreparedOn.ToString("dd/MM/yyyy")
            </td>
        </tr>
        <tr>
            <th align="center">
                @Resources_frank.Budget_CategoryList_ProjectNo
            </th>
            <th align="center">
                @Resources_frank.Global_String_PreparedByTitle
            </th>
            <th align="center" width="17%">
                @Resources_frank.ProcurementPlan_CreatePPStep2_ProjectStartDate
            </th>
            <th align="center" width="17%">
                @Resources_frank.ProcurementPlan_CreatePPStep2_ProjectEndDate
            </th>
        </tr>
        <tr>
            <td align="center" title="@Model.EntityPP.ProjectDonor.Project.Name">
                @Model.EntityPP.ProjectDonor.ProjectNumber
            </td>
            <td align="center">
                @Model.EntityPP.Staff.Designation.Name
            </td>
            <td align="center">
                @Model.EntityPP.ProjectDonor.StartDate.ToString("dd/MM/yyyy")
            </td>
            <td align="center">
                @Model.EntityPP.ProjectDonor.EndDate.ToString("dd/MM/yyyy")
            </td>
        </tr>
    </table>   
    <center>  
        @Ajax.ActionLink(Resources_frank.ProcurementPlan_CreatePPStep2_AddItemToPP, "CreatePPItem", new { ppId = Model.EntityPP.Id }, new AjaxOptions
        {
            OnBegin = string.Format("ShowDialogue('{0}')", Resources_frank.ProcurementPlan_CreatePPStep2_AddItemToPP),
            UpdateTargetId = "popup-page",
            LoadingElementId = "popup-loading",
            OnSuccess = "ClearForm();CenterPopup();"
        }) 
    </center>

    @if (Model.PPItems.Count > 0)
    {
        <table align="center" width="98%" class="cardTable">
            <tr>
                <th>@Resources_frank.OrderRequest_AddPPItems2OR_DescriptionOfGoods</th>
                <th>@Resources_frank.OrderRequest_AddPPItems2OR_TechincalSpecification</th>
                <th>@Resources_morgan.Global_String_Unit</th>
                <th>@Resources_frank.Global_String_Qty</th>
                <th>@Resources_frank.OrderRequest_AddItemInEditMode_EstUnitPrice</th>
                <th>@Resources_frank.OrderRequest_AddItemInEditMode_EstTotalPrice</th>
                <th>@Resources_frank.Global_String_Currency</th>
                <th>@Resources_frank.Budget_CreateSubLine_LineNumber</th>
                <th>@Resources_frank.OrderRequest_AddPPItems2OR_RequiredDeliveryLocation</th>
                <th>@Resources_frank.OrderRequest_AddPPItems2OR_RequiredDeliveryDate</th>
                <th>@Resources_frank.Global_String_Manage</th>
            </tr>
            @foreach (var item in Model.PPItems)
            {
                <tr>                
                    <td>@item.EntityPPItem.Item.Name</td>
                    <td>@item.EntityPPItem.ItemDescription</td>
                    <td>@item.EntityPPItem.Item.UnitOfMeasure.Code</td>
                    <td align="center">@item.EntityPPItem.Quantity</td>
                    <td align="right">@item.EntityPPItem.UnitCost.ToString("#,##0.00")</td>
                    <td align="right">@item.EntityPPItem.TotalCost.ToString("#,##0.00")</td>
                    <td align="center">@item.EntityPPItem.Currency.ShortName</td>
                    <td align="center">@item.EntityPPItem.ProjectBudget.LineNumber</td>
                    <td>@item.EntityPPItem.Location.Name</td>
                    <td align="right">@item.EntityPPItem.RequiredDeliveryDate.ToString("dd/MM/yyyy")</td>
                    <td align="center">
                        @Ajax.ActionLink(Resources_frank.Global_String_Edit, "EditPPItem", new AjaxOptions
                        {
                            OnBegin = string.Format("ShowDialogue('{0}')", Resources_frank.ProcurementPlan_CreatePPStep2_EditPPItem),
                            UpdateTargetId = "popup-page",
                            LoadingElementId = "popup-loading",
                            Url = Url.Action("EditPPItem/" + item.EntityPPItem.Id),
                            OnSuccess = "CenterPopup();"
                        }) 
                        @Ajax.ActionLink(Resources_frank.Global_String_Remove, "RemovePPItem", new AjaxOptions
                        {
                            UpdateTargetId = "ppDiv",
                            LoadingElementId = "loading",
                            Url = Url.Action("RemovePPItem/" + item.EntityPPItem.Id),
                            Confirm = Resources_frank.ProcurementPlan_CreatePPStep2_ConfirmRemove
                        })
                    </td>
                </tr>
            }
        </table>
    }  
    
    <table align="center" width="98%">
        <tr>
            <td width="50%">
                <input type="button" class="btn green" value="@Resources_frank.ProcurementPlan_CreatePPStep2_EditPP" onclick="sendRequest('/ProcurementPlan/EditPP/@Model.EntityPP.Id', 'ppDiv', 'loading')" />
            </td>
            <td width="50%" align="right">
                @if (Model.PPItems.Count > 0)
                {
                    <input type="button" class="btn green" value="@Resources_frank.Global_String_Finish" onclick="sendRequest('/ProcurementPlan/SubmitPP/@Model.EntityPP.Id', 'ppDiv', 'loading');if (document.getElementById('table') != null) {initSorter();sorter.size(20);}" />
                }
            </td>
        </tr>
    </table>    
    
    <br />
</div>
         


